package com.huike.clues.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huike.clues.domain.TbActivity;
import com.huike.clues.domain.dto.TbActivityDTO;
import com.huike.clues.service.TbActivityService;
import com.huike.clues.mapper.TbActivityMapper;
import com.huike.common.utils.uuid.UUIDUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;

/**
 * @author 93238
 * @description 针对表【tb_activity(活动管理)】的数据库操作Service实现
 * @createDate 2023-10-12 06:35:46
 */
@Service
public class TbActivityServiceImpl extends ServiceImpl<TbActivityMapper, TbActivity>
        implements TbActivityService {


    @Autowired
    private TbActivityMapper tbActivityMapper;


    @Override
    public List<TbActivity> listTbActivity(TbActivityDTO tbActivityDTO) {
        return tbActivityMapper.listTbActivity(tbActivityDTO);
    }


    @Override
    public void add(TbActivity tbActivity) {
       tbActivity.setStatus("2");
       tbActivity.setCode(UUIDUtils.getUUID());
       tbActivity.setCreateTime(new Date());
       tbActivity.setUpdateTime(new Date());
       tbActivity.setCreateBy("1");
       tbActivityMapper.add(tbActivity);
    }


    @Override
    public TbActivity getDetailsById(Long id) {
        return  tbActivityMapper.getDetailsById(id);
    }


    @Override
    public void updateTbActivity(TbActivity tbActivity) {
        tbActivity.setUpdateTime(new Date());
        tbActivity.setUpdateBy("1");
        tbActivityMapper.updateTbActivity(tbActivity);
    }


    @Override
    public void deleteByIds(Long[] ids) {
        tbActivityMapper.deleteByIds(ids);
    }
}




